package com.dididoctor.patient.Activity.Diagnosis;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dididoctor.patient.Activity.Usercentre.Record.Cases.CasesDetail.Advice;
import com.dididoctor.patient.MV.EduActivity;
import com.dididoctor.patient.R;
import com.dididoctor.patient.Utils.Util;

import java.util.List;

/**
 * Created by Administrator on 2016/4/16.
 */
public class DiagnosisActivity extends EduActivity implements DiagnosisView {
    private TextView mTvHospital, mTvdate, mTvName, mTvJibing, mTvResult;

    //医生建议
    private TextView mTvSurvey, mTvMedicine, mTvSee, mTvOther;
    private LinearLayout mLlSurvey, mLlMedicine, mLlSee, mLlOther;
    private DiagnosisPresenter presenter;
    private String recId = "";

    @Override
    public void init() {
        recId = getIntent().getStringExtra("recId");
        mTvHospital = (TextView) findViewById(R.id.tv_hospital);
        mTvdate = (TextView) findViewById(R.id.tv_date);
        mTvJibing = (TextView) findViewById(R.id.tv_jibing);
        mTvName = (TextView) findViewById(R.id.tv_doctorname);
        mTvResult = (TextView) findViewById(R.id.tv_result);
        //医生建议
        mTvSurvey = (TextView) findViewById(R.id.tv_survey);
        mTvMedicine = (TextView) findViewById(R.id.tv_medicine);
        mTvSee = (TextView) findViewById(R.id.tv_see);
        mTvOther = (TextView) findViewById(R.id.tv_other);
        mLlSurvey = (LinearLayout) findViewById(R.id.ll_survey);
        mLlMedicine = (LinearLayout) findViewById(R.id.ll_medicine);
        mLlSee = (LinearLayout) findViewById(R.id.ll_see);
        mLlOther = (LinearLayout) findViewById(R.id.ll_other);

        presenter = new DiagnosisPresenter(this, this);
        presenter.getDiagnosis(recId);
    }

    @Override
    public void onClickEvent(View view) {

    }

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_diagnosis);
    }

    @Override
    public void getDiagnosis(Diagnosis diagnosis, List<Advice> advices) {
        if (diagnosis != null) {
            mTvHospital.setText(diagnosis.getHosName());
            mTvdate.setText(diagnosis.getClinicDate());
            mTvName.setText(diagnosis.getDctName());
            mTvJibing.setText(diagnosis.getDescr());
            mTvResult.setText(diagnosis.getResult());
        }
        if (!Util.isEmpty(advices)) {
            for (int i = 0; i < advices.size(); i++) {
                Advice advice = advices.get(i);
                if ("1".equals(advice.getType())) {
                    mLlSurvey.setVisibility(View.VISIBLE);
                    mLlMedicine.setVisibility(View.GONE);
                    mLlSee.setVisibility(View.GONE);
                    mLlOther.setVisibility(View.GONE);
                    mTvSurvey.setText(advice.getContent());
                } else if ("2".equals(advice.getType())) {
                    mLlSurvey.setVisibility(View.GONE);
                    mLlMedicine.setVisibility(View.GONE);
                    mLlSee.setVisibility(View.VISIBLE);
                    mLlOther.setVisibility(View.GONE);
                    mTvSee.setText(advice.getContent());
                } else if ("3".equals(advice.getType())) {
                    mLlSurvey.setVisibility(View.GONE);
                    mLlMedicine.setVisibility(View.VISIBLE);
                    mLlSee.setVisibility(View.GONE);
                    mLlOther.setVisibility(View.GONE);
                    mTvMedicine.setText(advice.getContent());
                } else if ("4".equals(advice.getType())) {
                    mLlSurvey.setVisibility(View.GONE);
                    mLlMedicine.setVisibility(View.GONE);
                    mLlSee.setVisibility(View.GONE);
                    mLlOther.setVisibility(View.VISIBLE);
                    mTvOther.setText(advice.getContent());
                }
            }
        }
    }

    @Override
    public void getDiagnsisfail() {

    }
}
